package com.hkemmm.bean;

import java.io.Serializable;

public class AjaxRes implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 返回码值,默认值Const.SUCCEED
     */
    private int code = Const.SUCCEED;
    /**
     * 返回码值解析
     */
    private String resMsg;
    /**
     * 总数页
     */
    private long totalPage;
    /**
     * 总记录数
     */
    private long totalRecord;
    /**
     * 返回对象
     */
    private Object obj;


    /**
     * 设置成功值
     *
     * @param obj    设置对象
     * @param resMsg 设置码值解析
     */
    public void setSucceed(Object obj, String resMsg) {
        this.setResMsg(resMsg);
        this.setSucceed(obj);
    }

    /**
     * 设置成功值
     *
     * @param obj 设置对象
     */
    public void setSucceed(Object obj) {
        this.obj = obj;
        this.setCode(Const.SUCCEED);
    }

    /**
     * 设置成功值
     *
     * @param resMsg 返回码值解析
     */
    public void setSucceedMsg(String resMsg) {
        this.setCode(Const.SUCCEED);
        this.setResMsg(resMsg);
    }

    /**
     * 设置失败值
     *
     * @param resMsg 返回码值解析
     */
    public void setFailMsg(String resMsg) {
        this.obj = null;
        this.setCode(Const.FAIL);
        this.setResMsg(resMsg);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getResMsg() {
        return resMsg;
    }

    public void setResMsg(String resMsg) {
        this.resMsg = resMsg;
    }

    public long getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(long totalPage) {
        this.totalPage = totalPage;
    }

    public long getTotalRecord() {
        return totalRecord;
    }

    public void setTotalRecord(long totalRecord) {
        this.totalRecord = totalRecord;
    }

    public Object getObj() {
        return obj;
    }

    public void setObj(Object obj) {
        this.obj = obj;
    }
}
